home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cpp_libs / nihcl-30.lha / nihcl-3.0 / lib / Collection.h < prev    next >
C/C++ Source or Header  |  1990-05-19  |  3KB  |  82 lines

  1. #ifndef    COLLECTION_H
  2. #define    COLLECTION_H
  3.  
  4. /*$Header: /afs/alw.nih.gov/unix/sun4_40c/usr/local/src/nihcl-3.0/share/lib/RCS/Collection.h,v 3.0 90/05/20 00:19:21 kgorlen Rel $*/
  5.  
  6. /* Collection.h -- declarations for abstract Collection class
  7.  
  8.     THIS SOFTWARE FITS THE DESCRIPTION IN THE U.S. COPYRIGHT ACT OF A
  9.     "UNITED STATES GOVERNMENT WORK".  IT WAS WRITTEN AS A PART OF THE
  10.     AUTHOR'S OFFICIAL DUTIES AS A GOVERNMENT EMPLOYEE.  THIS MEANS IT
  11.     CANNOT BE COPYRIGHTED.  THIS SOFTWARE IS FREELY AVAILABLE TO THE
  12.     PUBLIC FOR USE WITHOUT A COPYRIGHT NOTICE, AND THERE ARE NO
  13.     RESTRICTIONS ON ITS USE, NOW OR SUBSEQUENTLY.
  14.  
  15. Author:
  16.     K. E. Gorlen
  17.     Computer Systems Laboratory, DCRT
  18.     National Institutes of Health
  19.     Bethesda, MD 20892
  20.  
  21. $Log:    Collection.h,v $
  22.  * Revision 3.0  90/05/20  00:19:21  kgorlen
  23.  * Release for 1st edition.
  24.  * 
  25. */
  26.  
  27. #include "Object.h"
  28.  
  29. class ArrayOb;
  30. class Bag;
  31. class Heap;
  32. class Iterator;
  33. class OrderedCltn;
  34. class Set;
  35. class SortedCltn;
  36.  
  37. class Collection: public VIRTUAL Object {    // abstract class 
  38.     DECLARE_MEMBERS(Collection);
  39. public:
  40.     static const unsigned DEFAULT_CAPACITY;        // default initial collection capacity 
  41.     static const unsigned EXPANSION_INCREMENT;    // collection (OrderedCltn) expansion increment 
  42.     static const unsigned EXPANSION_FACTOR;        // collection (Set,Bag,Dictionary) expansion factor 
  43. protected:
  44.     Collection();
  45. protected:        // _storer() functions for object I/O
  46.     void _storer(OIOofd&) const;        // store collection using Iterator
  47.     void _storer(OIOout&) const;        // store collection using Iterator
  48. public:
  49.     ArrayOb asArrayOb() const;
  50.     Bag asBag() const;
  51.     Heap asHeap() const;
  52.     OrderedCltn asOrderedCltn() const;
  53.     Set asSet() const;
  54.     SortedCltn asSortedCltn() const;
  55.     virtual ~Collection();        // Collection destructors are virtual
  56.     virtual    Object* add(Object&) = 0;
  57.     virtual const Collection& addAll(const Collection&);
  58.     virtual Collection& addContentsTo(Collection&) const;
  59.     virtual Object*& at(int) = 0;
  60.     virtual const Object *const& at(int) const = 0;
  61.     virtual int compare(const Object&) const = 0;
  62.     virtual    void deepenShallowCopy();   // {}
  63.     virtual    void doFinish(Iterator& pos) const;
  64.     virtual    Object* doNext(Iterator&) const = 0;
  65.     virtual    void doReset(Iterator& pos) const;
  66.     virtual void dumpOn(ostream& strm =cerr) const;
  67.     virtual unsigned hash() const = 0;
  68.     virtual bool includes(const Object&) const;
  69.     virtual bool isEmpty() const;
  70.     virtual bool isEqual(const Object&) const = 0;
  71.     virtual unsigned occurrencesOf(const Object&) const = 0;
  72.     virtual void printOn(ostream& strm =cout) const;
  73.     virtual Object* remove(const Object&) = 0;
  74.     virtual void removeAll() = 0;
  75.     virtual const Collection& removeAll(const Collection&);
  76.     virtual unsigned size() const = 0;
  77. };
  78.  
  79. #include "Iterator.h"
  80.  
  81. #endif
  82.